﻿#ifndef DIGITALARCHIVEFRM_H
#define DIGITALARCHIVEFRM_H

#include <QWidget>
#include <QSqlDatabase>
#include <digitalarchives/cadre.h>
#include <digitalarchives/qwgraphicsview.h>
#include <QMouseEvent>
#include <QMainWindow>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QImage>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QFileDialog>
#include <QPainter>
#include <QLineEdit>
#include <QPixmap>
#include <QListWidgetItem>
#include <QGraphicsPixmapItem>
#include <QTreeWidgetItem>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsPolygonItem>

namespace Ui {
class DigitalArchiveFrm;
}

class DigitalArchiveFrm : public QWidget
{
    Q_OBJECT

public:
    explicit DigitalArchiveFrm(QWidget *parent = 0);
    ~DigitalArchiveFrm();


private slots:
    void on_btn_showdir_clicked();

    void departTree(QString root, QTreeWidget *tree);

    void departTree(QString root, QTreeWidgetItem *item);

    void on_btn_screenshot_clicked();

    QString get_archive_type();

    QImage capture(int x, int y, QSize captureSize, QSize Imgsize, QString img);

    void on_btn_change_clicked();

    void on_btn_insert_clicked();

    void on_btn_delete_clicked();

    void on_btn_importimg_clicked();

    void on_btn_exportimg_clicked();

    void ImgShow(QImage *image);

    void on_btn_zoomout_clicked();

    void on_btn_rotate_clicked();

    void on_btn_zoomin_clicked();

    void on_btn_cadreselection_clicked();

    void on_listWidget_itemChanged(QListWidgetItem *item);

    void on_tableView_clicked(const QModelIndex &index);

    void on_listWidget_clicked(const QModelIndex &index);

    void reshow(QString text, QString id);

    void on_mouseMovePoint(QPoint point);

    void on_mouseClicked(QPoint point);

    void on_mouseReleased(QPoint point);

    void showDirFile(QDir  dir);

    void on_btn_topdf_clicked();

signals:
    void sendSignal(QString, QString);

    void mouseMovePoint(QPoint);

    void mouseClicked(QPoint);

    void mousePressed(QPoint);

private:
    Ui::DigitalArchiveFrm *ui;
    QString fileName;
    QString dirpath;
    QString cadre_id, db_name;
    QSqlQuery *query;

    QImage *image;
    QImage img_opt;//截图后的图片
    QPixmap img_save;  //QLabel中显示的要保存的图片
    int dir_count;   //当前目录下文件个数
    float pixRatio;//当前图片缩放比例
    float num = 1;
    int rotate = 0;
    QPainterPath m_Path;
    bool isEnd;
    QGraphicsScene *scene;
    CCadre *cadre;
    QListWidgetItem *item;
    QGraphicsPixmapItem *pixmapitem;

    QString archive_type, cadre_name, arcname, cadrename;
    int currow, curpage;
    QGraphicsPolygonItem *image_item;

    int x_start, y_start, x_end, y_end;
    QPointF pointScene_start, pointScene_end;

    //枚举类型treeItemType， 用于创建 QTreeWidgetItem 时作为节点的type, 自定义类型必须大于1000
    //itTopItem 顶层节点;  itGroupItem 组节点； itImageItem 图片
    enum treeItemType {
        itTopItem = 1001, itGroupItem, itImageItem
    };

};

#endif // DIGITALARCHIVEFRM_H
